import React from 'react'
import { Link } from 'react-router-dom'
import Menu from '@/views/Menu'
import '@/assets/css/BusinessIndex.scoped.css'

const Component = () =>
{
  //退出登录
  const logout = async () =>
  {
    //弹出提示框
    var result = await React.UI.Dialog.confirm({
      content: '是否确认退出'
    })
    
    //点击了确认
    if(result) 
    {
        React.business = {}
        React.cookies.remove('business')
        React.navigate('/business/login')
    }
  }

  return (
    <>
        {/* <div className='top'></div> */}
        <div className="header">
            <div className="userinfo">
                <div className="avatar">
                    <img src={React.business.avatar_text} />
                </div>
                <div className="nickname">{React.business.nickname}</div>
                <div className="content">这家伙很懒，什么也没写！</div>
            </div>
            <div className="corrugated">
                <div className="wave-top wave-item"></div>
                <div className="wave-middle wave-item"></div>
                <div className="wave-bottom wave-item"></div>
            </div>
        </div>
        
        <div className="menu-cell">
            <div className="item">
                <Link to={'/business/profile'}>
                    <div className="title">个人资料</div>
                    <div className="icon">
                        <img src={require("@/assets/images/right.png")} />
                    </div>
                </Link>
            </div>
            
            <div className="item">
                {
                    React.business.auth !== '1' &&
                    <Link to={"/business/email"}>
                        <div className="title">邮箱验证</div>
                        <div className="icon">
                            <img src={require("@/assets/images/right.png")} />
                        </div>
                    </Link>
                }
                
            </div>
            
            <div className="item">
                <Link to={"/order"}>
                    <div className="title">我的订单</div>
                    <div className="icon">
                        <img src={require("@/assets/images/right.png")} />
                    </div>
                </Link>
            </div>

            <div className="item">
                <Link to={"/guest"}>
                    <div className="title">住客信息</div>
                    <div className="icon">
                        <img src={require("@/assets/images/right.png")} />
                    </div>
                </Link>
            </div>

            <div className="item">
                <Link to={'/coupon'}>
                    <div className="title">我的优惠券</div>
                    <div className="icon">
                        <img src={require("@/assets/images/right.png")} />
                    </div>
                </Link>
            </div>
            
            <div className="item" onClick={logout}>
                <a>
                    <div className="title">退出登陆</div>
                    <div className="icon">
                        <img src={require("@/assets/images/right.png")} />
                    </div>
                </a>
            </div>
        </div>

      <Menu />
    </>
  )
}

export default Component